<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>

    <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

    <script type="text/babel">
      class App extends React.Component {
        constructor(props) {
          super(props)
          this.state = {
            message: 'Hello World',
            movies: ['大话西游', '西游记', '红楼梦', '三国演义']
          }
        }

        btnClick(event) {
          console.log(event)
        }

        liClick(item, index, e) {
          console.log('li标签被点击', item, index, e)
        }

        render() {
          return (
            <div>
              <h2>{this.state.message}</h2>
              <button onClick={this.btnClick}>按钮</button>

              <ul>
                {this.state.movies.map((item, index, arr) => {
                  return (
                    <li key={index} onClick={(e) => this.liClick(item, index, e)}>
                      {item}
                    </li>
                  )
                })}
              </ul>
            </div>
          )
        }
      }

      ReactDOM.render(<App />, document.querySelector('#app'))
    </script>
  </body>
</html>
